package org.example.heterogeneous;

import lombok.Data;

@Data
public class Edge implements Comparable<Edge> {

    private Integer u;

    private Integer v;

    // 支持度
    private Integer sup;

    // trussness
    private Integer trussness;

    public Edge() {
    }

    public Edge(int u, int v) {
        this.u = u;
        this.v = v;
    }

    public Edge(int u, int v, int sup) {
        this.u = u;
        this.v = v;
        this.sup = sup;
    }

    public Edge(int u, int v, int sup, int trussness) {
        this.u = u;
        this.v = v;
        this.sup = sup;
        this.trussness = trussness;
    }

    public void increaseSup() {
        if (getSup() != null) {
            setSup(getSup() + 1);
        } else {
            this.sup = 1;
        }
    }

    public void decreaseSup() {
        if (getSup() != null) {
            setSup(getSup() - 1);
        } else {
            this.sup = -1;
        }
    }

    @Override
    public int compareTo(Edge o) {
        return this.sup.compareTo(o.sup);
    }

    @Override
    public String toString() {
        return "边(" + u + "->" + v + "), sup=" + sup + ", trussness=" + trussness;
    }
}
